package com.owen.springboot.smartparkingms.module.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.owen.springboot.smartparkingms.common.model.Result;
import com.owen.springboot.smartparkingms.module.app.entity.ParkArea;
import com.owen.springboot.smartparkingms.module.app.mapper.ParkAreaMapper;
import com.owen.springboot.smartparkingms.module.app.service.IParkAreaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Owen
 * @since 2022-02-25
 */
@Service
public class ParkAreaServiceImpl extends ServiceImpl<ParkAreaMapper, ParkArea> implements IParkAreaService {

    @Resource
    ParkAreaMapper parkAreaMapper;

    @Override
    public Result listPage(ParkArea parkArea) {
        IPage<ParkArea> page = new Page(parkArea.getPageNo(),parkArea.getPageSize());
        QueryWrapper query = new QueryWrapper<>()
                .like("area",parkArea.getDescription());
        if(parkArea.getParkId()!=null){
            query.eq("park_id",parkArea.getParkId());
        }
        IPage<ParkArea> list = parkAreaMapper.selectPage(page,query);
        return Result.ok(list);
    }
}
